<?php
/**
 * @author wesley
 * @version v1.0
 * @time 2021/6/29 13:55
 * @desc
 */

namespace app\api\controller\v1;


use app\api\validate\IDMustBePositiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;

class Banner
{
    /**
     * 获取指定id的banner信息
     * @url /banner/:id
     * @http GET
     * @id banner的id号
     */
    public function getBanner($id): string
    {
        (new IDMustBePositiveInt())->goCheck();
//        $banner = BannerModel::getBannerByID($id);
        $banner = BannerModel::find($id);
        if(!$banner) {
            throw new BannerMissException();
        }
        return $banner;
    }
}